home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample PMSAM / PMSAM Framework / RoboSamSlot / CReport.cp < prev    next >
Encoding:
Text File  |  1995-07-28  |  2.5 KB  |  144 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CReport.cp
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Tim Harnett
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <1>    12/12/94    TMH        seperated for MailHandler.cp
  13.                  12/5/94    TMH        xxx put comment here xxx
  14.  
  15.     To Do:
  16. */
  17.  
  18. #ifndef __STRING__
  19. #include "String.h"
  20. #endif
  21.  
  22. #ifndef __Globals__
  23. #include "Globals.h"
  24. #endif
  25.  
  26. #ifndef __Debug__
  27. #include "Debug.h"
  28. #endif
  29.  
  30.  
  31. #ifndef __CDSSpec__
  32. #include "CDSSpec.h"
  33. #endif
  34.  
  35. #ifndef __CReport__
  36. #include "CReport.h"
  37. #endif
  38.  
  39. #ifndef __TThread__
  40. #include "TThread.h"
  41. #endif
  42.  
  43.  
  44. //----------------------------
  45. //        C R e p o r t
  46. //----------------------------
  47.  
  48.  
  49. //-------------------------------------------------------------------------
  50. CReport::CReport(MailMsgRef msgRef,MailLetterID letterID)
  51. {
  52.     fMsgRef = msgRef;
  53.     fLetterID = letterID;
  54.     
  55.     fReportRef = 0;
  56.     memset(&fPB,0,sizeof(MSAMParam));
  57. }
  58.  
  59.  
  60. //-------------------------------------------------------------------------
  61. CReport::~CReport()
  62. {
  63.     if(fReportRef != 0 )
  64.         this->Submit(false);
  65. }
  66.  
  67.  
  68. //------------------------------------------------------------------------
  69. OSErr CReport::Create()
  70. {
  71.  
  72.     fPB.header.ioCompletion = 0;
  73.     fPB.msamCreateReport.msgID = fLetterID;
  74.  
  75.  
  76.     CRecipientIterator    fromIter(fMsgRef,kMailFromBit);
  77.     OrigRecipient* fromRecip = fromIter.FirstRecipient();
  78.     CUnpackedDSSpec sender(&fromRecip->packedRecip);
  79.  
  80.     fPB.msamCreateReport.sender = (MailRecipient*)&sender;
  81.  
  82.  
  83.     MSAMCreateReport(&fPB,true);
  84.     do {
  85.         gCurrentThread->Yield();
  86.     } while( fPB.header.ioResult > 0 );
  87.  
  88.  
  89.     ASSERTNOERR(fPB.header.ioResult);
  90.  
  91.     fReportRef = fPB.msamCreateReport.mailMsgRef;
  92.  
  93.     return fPB.header.ioResult;
  94.  
  95. }
  96.  
  97.  
  98. //------------------------------------------------------------------------
  99. OSErr CReport::Submit(Boolean submit)
  100. {
  101.     ASSERT(fReportRef!=0);
  102.     
  103.     fPB.msamSubmit.mailMsgRef = fReportRef;
  104.     fPB.msamSubmit.submitFlag = submit;
  105.     
  106.     OSErr osErr = MSAMSubmit(&fPB);
  107.     ASSERTNOERR(osErr);
  108.     
  109.     fReportRef = 0;
  110.     
  111.     return osErr;
  112.  
  113. }
  114.  
  115.  
  116.  
  117.  
  118. //------------------------------------------------------------------------
  119. OSErr CReport::PutRecipientReport(OSErr reportErr,ResolvedRecipient* resolvedRecipient)
  120. {
  121.  
  122.     fPB.msamPutRecipientReport.mailMsgRef = fReportRef;
  123.     fPB.msamPutRecipientReport.recipientIndex = resolvedRecipient->ext.index;        // the report index
  124.     fPB.msamPutRecipientReport.result = reportErr;
  125.  
  126.  
  127.     MSAMPutRecipientReport(&fPB,true);
  128.     do {
  129.         gCurrentThread->Yield();
  130.     } while( fPB.header.ioResult > 0 );
  131.  
  132.  
  133.     ASSERTNOERR(fPB.header.ioResult);
  134.     
  135.     return fPB.header.ioResult;
  136. }
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143. //•••
  144.